Merged
Conversation
I installed Vitest, @vitest/ui, jsdom, @testing-library/react, and @testing-library/jest-dom. I configured Vitest to work with React and TypeScript: - Created `vitest.config.ts`. - Created `src/setupTests.ts` to import `@testing-library/jest-dom`. - Added `test` and `test:ui` scripts to `package.json`. I added initial tests for components: - A basic rendering test for the `Button` component. - Smoke tests for all other components in the `src` directory to ensure they render without crashing. Note: Due to persistent issues with the `pnpm` environment, I could not run the tests to confirm their passing status. I've created the setup and test files, but further verification in a stable environment will be required.
I've added a new GitHub Actions workflow (`.github/workflows/test.yml`) that triggers on push and pull requests to the main branch. The workflow performs the following steps: - Checks out the repository code. - Sets up Node.js v18. - Caches pnpm modules for faster builds. - Installs pnpm. - Installs project dependencies using pnpm. - Runs your test suite using `pnpm test`. This will help automate the testing process and ensure tests are run consistently.
Corrected the import statements in all component test files to use the actual exported component names (e.g., `NesButton`, `NesCheckbox`). Many components were being imported with generic names like `Button` while the actual exports were prefixed with `Nes`. Additionally, updated several smoke tests to include necessary props required for the components to render without errors, even for basic rendering checks. The `Dialog` component test was specifically corrected to reflect its actual implementation, which exports a `Dialog` component taking no props, after a previous erroneous correction attempt. These changes should resolve the "Element type is invalid" errors reported when running the tests.
✅ Deploy Preview for react-nes-components ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull Request Overview
Adds Vitest as the testing framework, includes smoke tests for individual UI components, updates package.json with Vitest scripts/dependencies, and configures a GitHub Actions workflow to run tests on CI.
- Introduce a basic render smoke test for each component under
src/... - Add Vitest, Testing Library, and related devDependencies and scripts
- Add
.github/workflows/test.ymlto run tests on push/PR
Reviewed Changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src//.test.tsx | Add smoke test for each component to verify render |
| package.json | Add vitest, @vitest/ui, testing-library deps and scripts |
| .github/workflows/test.yml | CI workflow to install deps and run Vitest tests |
Comments suppressed due to low confidence (1)
src/Textarea/Textarea.test.tsx:7
- This test currently only checks for a crash. Consider adding at least one assertion (e.g.,
expect(container.firstChild).toBeInTheDocument()or a snapshot test) to verify that the component renders expected markup.
render(<Textarea />);
| @@ -0,0 +1,9 @@ | |||
| import { render } from '@testing-library/react'; | |||
There was a problem hiding this comment.
[nitpick] Nearly identical smoke tests are duplicated across all component files. Consider using a parametrized test (e.g., describe.each) to loop through components and reduce boilerplate.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.